import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus, { ElLoading, ElMessage } from 'element-plus'
import 'element-plus/dist/index.css'
import axios from 'axios'
import VueCookies from 'vue-cookies'
import '@/assets/css/common.css'
import hljs from 'highlight.js'
import 'highlight.js/styles/atom-one-dark.css' // 样式

let loadingInstance1 = null
axios.interceptors.request.use(function (config) {
  loadingInstance1 = ElLoading.service({ fullscreen: true, text: '数据加载中' })
    return config
})
axios.interceptors.response.use(function (data) {
    loadingInstance1.close()
    return data
})
const app = createApp(App)
app.config.globalProperties.$cookies = VueCookies // 全局配置
// http://www.kymid.com/testphp/public/index.php/api/apis/type_list?lang=en
// 创建v-highlight全局指令
app.directive('highlight', function (el) {
  const blocks = el.querySelectorAll('pre code')
  blocks.forEach((block) => {
    hljs.highlightBlock(block)
  })
})
axios.defaults.baseURL = 'http://www.kymid.com/testphp/public/index.php/api/apis/'
// axios.defaults.baseURL = 'http://xxo.com/public/index.php/api/apis/'
app.config.globalProperties.$http = axios
app.config.globalProperties.$ElMessage = ElMessage
app.use(store).use(router).use(ElementPlus).mount('#app')
